﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fantacid303.ProcessAffinityControl.Manager.MainWindowViewModels
{
	/// <summary>
	/// Represents the ViewModel of a process identified by the process ID (PID)
	/// </summary>
	partial class ProcessViewModel : ViewModelBase
	{
		private uint pid;
		private uint affinityMask;
		private string name;

		/// <summary>
		/// Initializes a new instance of the <see cref="ProcessViewModel"/> class.
		/// </summary>
		/// <param name="processId">The process id.</param>
		/// <param name="configurationViewModel">The configuration view model.</param>
		public ProcessViewModel(uint processId, ConfigurationViewModel configurationViewModel)
		{
			this.PID = processId;
			this.ConfigurationViewModel = configurationViewModel;
		}

		/// <summary>
		/// Gets the configuration view model which is the parent of this instance
		/// </summary>
		/// <value>The configuration view model.</value>
		public ConfigurationViewModel ConfigurationViewModel
		{ get; private set; }

		/// <summary>
		/// Gets or sets the selected process id (PID)
		/// </summary>
		public uint PID
		{
			get { return pid; }
			set
			{
				if (pid == value)
					return;

				pid = value;
				this.OnPropertyChanged("PID");
			}
		}

		/// <summary>
		/// Gets or sets the processor affinity mask of the given process
		/// </summary>
		public uint AffinityMask
		{
			get { return affinityMask; }
			set
			{
				if (affinityMask == value)
					return;

				affinityMask = value;
				this.OnPropertyChanged("AffinityMask");
			}
		}

		/// <summary>
		/// Gets or sets the name of the process
		/// </summary>
		public string Name
		{
			get { return name; }
			set
			{
				if (name == value)
					return;

				name = value;
				this.OnPropertyChanged("Name");
			}
		}
	}
}
